package com.example.springbootvuetest.exception;

import com.example.springbootvuetest.base.ResultCode;

/**
 * @Description: 自定义异常处理类
 * @Author shuoye
 * @Date 2023/3/4
 * @Version 1.0
 */
public class MyException extends RuntimeException{
    private Integer code;

    public MyException() {
    }

    public MyException(String message) {
        super(message);
    }

    public MyException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public MyException(ResultCode resultCode) {
        super(resultCode.getMsg());
        this.code = resultCode.getCode();
    }

    public MyException(String message, Throwable cause) {
        super(message, cause);
    }

    public MyException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public MyException(ResultCode resultCode, Throwable cause) {
        super(resultCode.getMsg(), cause);
        this.code = resultCode.getCode();
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
